home *** CD-ROM | disk | FTP | other *** search
/ Treccani Italiana Di Scienze Lettere Ed Arti / [Enciclopedia] Treccani Italiana di scienze lettere ed arti.iso / mac / data / xxi_appendice_dvd.swf / scripts / __Packages / CAppendiceZoom.as < prev    next >
Text File  |  2007-11-08  |  8KB  |  209 lines

  1. class CAppendiceZoom extends mx.core.UIObject
  2. {
  3.    function CAppendiceZoom()
  4.    {
  5.       super();
  6.       this.Hide();
  7.       this.doLater(this,"init");
  8.    }
  9.    function init(Void)
  10.    {
  11.       this.mMarginRect = new Object();
  12.       this.mMarginRect.top = 42;
  13.       this.mMarginRect.left = 42;
  14.       this.mMarginRect.bottom = 51;
  15.       this.mMarginRect.right = 42;
  16.       this.mMaxZoom = 100;
  17.       this.mMinZoom = 25;
  18.       this.mc_ZoomPanelOrgRect = new Object();
  19.       this.mc_ZoomPanelOrgRect.x = this.mc_ZoomPanel._x;
  20.       this.mc_ZoomPanelOrgRect.y = this.mc_ZoomPanel._y;
  21.       this.mc_ZoomPanelOrgRect.width = this.mc_ZoomPanel.width;
  22.       this.mc_ZoomPanelOrgRect.height = this.mc_ZoomPanel.height;
  23.       this.mc_ZoomCloseBtn.useHandCursor = false;
  24.       this.mGrabAlpha = 10;
  25.       this.mc_ZoomPanel.addEventListener("progress",mx.utils.Delegate.create(this,this.onImageLoadingProgress));
  26.       this.mc_ZoomPanel.addEventListener("complete",mx.utils.Delegate.create(this,this.onImageLoadingComplete));
  27.       this.mc_ZoomPanel.setStyle("borderStyle","none");
  28.       this.mc_ZoomPanel.__set__scrollDrag(true);
  29.       this.mc_ZoomTitle.html = true;
  30.       this.mc_ZoomTitle.embedFonts = _global.gUseEmbeddedFont;
  31.       this.mc_ZoomTitle.styleSheet = _global.gStyleManager.GetCSS();
  32.       this.mc_ZoomProgress._visible = false;
  33.       this.mc_ZoomBkg.onPress = this.ClickGrab;
  34.       this.mc_ZoomBkg.useHandCursor = false;
  35.       this.mc_ZoomTitleRollover.onRollOver = mx.utils.Delegate.create(this,this.onZoomTitleRollOver);
  36.       this.mc_ZoomTitleRollover.onRollOut = mx.utils.Delegate.create(this,this.onZoomTitleRollOut);
  37.       this.mc_ZoomTitleRollover.onDragOut = mx.utils.Delegate.create(this,this.onZoomTitleRollOut);
  38.    }
  39.    function ClickGrab()
  40.    {
  41.    }
  42.    function LayoutWindow()
  43.    {
  44.       this.mc_ZoomProgress._visible = false;
  45.       var _loc2_ = {x:0,y:0};
  46.       this.globalToLocal(_loc2_);
  47.       this.mc_ZoomGrab._x = _loc2_.x;
  48.       this.mc_ZoomGrab._y = _loc2_.y;
  49.       this.mc_ZoomGrab._width = Stage.width;
  50.       this.mc_ZoomGrab._height = Stage.height;
  51.       this.mc_ZoomGrab.onPress = function()
  52.       {
  53.          this._parent.NextFrame();
  54.       };
  55.       this.mc_ZoomGrab.useHandCursor = false;
  56.       this.mc_ZoomGrab._alpha = this.mGrabAlpha;
  57.       this.mc_ZoomGrab._visible = true;
  58.    }
  59.    function ZoomImage(inHtmlTitolo, inUrl)
  60.    {
  61.       this.LayoutWindow();
  62.       this.mc_ZoomTitle.text = "<span class=\'s_titoloContributo\'>" + inHtmlTitolo + "</span>";
  63.       this.mc_ZoomTitle.hscroll = 0;
  64.       if(inUrl != this.mc_ZoomPanel.__get__contentPath())
  65.       {
  66.          this.mc_ZoomPanel.__set__contentPath(inUrl);
  67.          this.mc_ZoomProgress.Setprogress(0);
  68.          this.mc_ZoomProgress._visible = true;
  69.       }
  70.       this.mc_ZoomProgress._visible = false;
  71.       this._visible = true;
  72.       this.dispatchEvent({type:"onXXIWindowMessage",target:this,windowName:"zoom",action:"open"});
  73.    }
  74.    function ZoomContributo(inContributo, inFrom)
  75.    {
  76.       this.LayoutWindow();
  77.       this.mc_ZoomTitle.text = "<span class=\'s_titoloContributo\'>" + inContributo.mTitolo + "</span>";
  78.       this.mc_ZoomTitle.hscroll = 0;
  79.       var _loc2_ = inContributo.GetPath();
  80.       if(_loc2_ != this.mc_ZoomPanel.__get__contentPath())
  81.       {
  82.          this.mc_ZoomPanel.__set__contentPath(_loc2_);
  83.          this.mc_ZoomProgress.Setprogress(0);
  84.          this.mc_ZoomProgress._visible = true;
  85.       }
  86.       this._visible = true;
  87.       this.dispatchEvent({type:"onXXIWindowMessage",target:this,windowName:"zoom",action:"open"});
  88.    }
  89.    function Hide(Void)
  90.    {
  91.       this._visible = false;
  92.    }
  93.    function Close(Void)
  94.    {
  95.       this.Hide();
  96.       this.dispatchEvent({type:"onXXIWindowMessage",target:this,windowName:"zoom",action:"close"});
  97.    }
  98.    function onImageLoadingProgress(eventObject)
  99.    {
  100.       if(this.mc_ZoomPanel.getBytesTotal() > 0)
  101.       {
  102.          this.mc_ZoomProgress.Setprogress(this.mc_ZoomPanel.getBytesLoaded() / this.mc_ZoomPanel.getBytesTotal() * 100);
  103.       }
  104.    }
  105.    function onImageLoadingComplete(eventObject)
  106.    {
  107.       this.mc_ZoomProgress._visible = false;
  108.    }
  109.    function FitImageToPanelArea()
  110.    {
  111.       this.mc_ZoomPanel.__get__content()._orgWidth = this.mc_ZoomPanel.__get__content()._width;
  112.       this.mc_ZoomPanel.__get__content()._orgHeight = this.mc_ZoomPanel.__get__content()._height;
  113.       this.mc_ZoomProgress._visible = false;
  114.       this.ScaleContent(0);
  115.    }
  116.    function ScaleContent(inScale)
  117.    {
  118.       if(!this.mc_ZoomPanel.__get__content())
  119.       {
  120.          return undefined;
  121.       }
  122.       this.UnScaleContent();
  123.       var _loc5_ = this.mc_ZoomPanel.__get__width() - 18;
  124.       var _loc8_ = this.mc_ZoomPanel.__get__height() - 18;
  125.       var _loc4_ = 0;
  126.       var _loc3_ = 0;
  127.       var _loc2_ = undefined;
  128.       if(inScale == 0)
  129.       {
  130.          var _loc7_ = _loc5_ / this.mc_ZoomPanel.__get__content()._width;
  131.          var _loc6_ = _loc8_ / this.mc_ZoomPanel.__get__content()._height;
  132.          if(_loc7_ > _loc6_)
  133.          {
  134.             _loc4_ = Math.floor((_loc5_ - this.mc_ZoomPanel.__get__content()._width * _loc6_) / 2);
  135.             _loc2_ = _loc6_ * 100;
  136.          }
  137.          else
  138.          {
  139.             _loc3_ = Math.floor((_loc8_ - this.mc_ZoomPanel.__get__content()._height * _loc7_) / 2);
  140.             _loc2_ = _loc7_ * 100;
  141.          }
  142.       }
  143.       else
  144.       {
  145.          _loc2_ = inScale;
  146.          _loc4_ = Math.max(0,Math.floor((_loc5_ - this.mc_ZoomPanel.__get__content()._orgWidth * _loc2_ / 100) / 2));
  147.          _loc3_ = Math.max(0,Math.floor((_loc8_ - this.mc_ZoomPanel.__get__content()._orgHeight * _loc2_ / 100) / 2));
  148.       }
  149.       this.mc_ZoomPanel.__get__content()._xscale = this.mc_ZoomPanel.__get__content()._yscale = _loc2_;
  150.       this.mc_ZoomPanel._x = this.mc_ZoomPanelOrgRect.x + _loc4_;
  151.       this.mc_ZoomPanel._y = this.mc_ZoomPanelOrgRect.y + _loc3_;
  152.       var _loc11_ = this.mc_ZoomPanelOrgRect.width;
  153.       if(_loc4_ > 0)
  154.       {
  155.          _loc11_ -= _loc4_;
  156.       }
  157.       var _loc9_ = this.mc_ZoomPanelOrgRect.height;
  158.       if(_loc3_ > 0)
  159.       {
  160.          _loc9_ -= _loc3_;
  161.       }
  162.       this.mc_ZoomPanel.invalidate();
  163.    }
  164.    function UnScaleContent()
  165.    {
  166.       if(!this.mc_ZoomPanel.__get__content())
  167.       {
  168.          return undefined;
  169.       }
  170.       this.mc_ZoomPanel.__get__content()._xscale = this.mc_ZoomPanel.__get__content()._yscale = 100;
  171.       this.mc_ZoomPanel.__get__content()._x = this.mc_ZoomPanel.__get__content()._y = 0;
  172.       this.mc_ZoomPanel._x = this.mc_ZoomPanelOrgRect.x;
  173.       this.mc_ZoomPanel._y = this.mc_ZoomPanelOrgRect.y;
  174.    }
  175.    function ZoomIn()
  176.    {
  177.       if(!this.mc_ZoomPanel.__get__content())
  178.       {
  179.          return undefined;
  180.       }
  181.       if(this.mc_ZoomPanel.__get__content()._xscale < this.mMaxZoom)
  182.       {
  183.          this.ScaleContent(Math.min(this.mc_ZoomPanel.__get__content()._xscale + 25,this.mMaxZoom));
  184.       }
  185.    }
  186.    function ZoomOut()
  187.    {
  188.       if(!this.mc_ZoomPanel.__get__content())
  189.       {
  190.          return undefined;
  191.       }
  192.       if(this.mc_ZoomPanel.__get__content()._xscale > this.mMinZoom)
  193.       {
  194.          this.ScaleContent(Math.max(this.mc_ZoomPanel.__get__content()._xscale - 25,this.mMinZoom));
  195.       }
  196.    }
  197.    function setEnabled(enable)
  198.    {
  199.    }
  200.    function onZoomTitleRollOver()
  201.    {
  202.       _root.gTooltipManager.show(this.mc_ZoomTitle.htmlText,null);
  203.    }
  204.    function onZoomTitleRollOut()
  205.    {
  206.       _root.gTooltipManager.hide();
  207.    }
  208. }
  209.